﻿using System.Collections.Generic;
using UnityEngine;
namespace NpcFramework
{
    public class NpcItemController : MonoBehaviour
    {
        [SerializeField]
        [Header("物品骨骼点")]
        private List<Transform> _itemList;

        [SerializeField]
        [Header("物品骨骼点的名字，必须与上一个一一对应")]
        private List<string> _nameList;
        public void HideAllItemPoint()
        {
            foreach (var item in _itemList)
            {
                item.localScale = Vector3.zero;
            }
        }

        public void SetItemPointActive(bool active,string name)
        {
            if (_nameList.Contains(name))
            {
                var index = _nameList.IndexOf(name);
                if (index < _itemList.Count)
                {
                    var item = _itemList[index];
                    item.localScale = active ? Vector3.one : Vector3.zero;
                }
                else
                {
                    Debug.LogError("该骨骼配置有问题：" + name);
                }
            }
        }
    }
}
